package com.kaoshi.user.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaoshi.user.config.AutoLog;
import com.kaoshi.common.config.Result;
import com.kaoshi.user.pojo.OperationLog;
import com.kaoshi.user.service.OperationLogService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-01
 */
@RestController
@RequestMapping("/a/operation-log")
public class OperationLogController {
    @Resource
    private OperationLogService operationLogService;

    @RequestMapping("/findPage")

    public Page<OperationLog> findPage(Integer page, Integer size, @RequestBody OperationLog operationLog) {
        return operationLogService.findPage(page, size, operationLog);
    }

    @RequestMapping("change")
    public Result change(@RequestBody OperationLog operationLog) {
        if (operationLog.getId() == null){
            operationLogService.add(operationLog);
        }else {
            operationLogService.updateById(operationLog);
        }
        return Result.ok();
    }

    @RequestMapping("delete")
    public Result delete(Integer id) {
        operationLogService.removeById(id);
        return Result.ok();
    }

}
